<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 
version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wadl="http://research.sun.com/wadl/2006/10"
exclude-result-prefixes="wadl"
>

<xsl:template match="/wadl:application">
<pre>
<xsl:apply-templates select="wadl:resources/wadl:resource" />
</pre>
</xsl:template>

<xsl:template match="wadl:resource">

== <xsl:for-each select="ancestor-or-self::wadl:resource">/<xsl:value-of select="@path" /></xsl:for-each> ==

<xsl:apply-templates select="wadl:doc" />

<xsl:for-each select="ancestor-or-self::wadl:resource">
<xsl:apply-templates select="wadl:param" />
</xsl:for-each>

<xsl:apply-templates select="wadl:method" />

<xsl:apply-templates select="wadl:resource" />
</xsl:template>

<xsl:template match="wadl:doc">
<xsl:copy-of select="." />
</xsl:template>

<xsl:template match="wadl:param">
  * `<xsl:value-of select="@name" />` as <xsl:value-of select="@style" /> (<xsl:if test="@required"><span class="required">required</span></xsl:if>)<xsl:apply-templates select="wadl:doc" /></xsl:template>

<xsl:template match="wadl:representation">
  * `<xsl:value-of select="@status" />`: <xsl:value-of select="@mediaType" /> with &lt;<xsl:value-of select="@element" />&gt;<xsl:apply-templates select="wadl:doc" /></xsl:template>

<xsl:template match="wadl:fault">
  * Possible fault codes: `<xsl:value-of select="@status" />`</xsl:template>

<xsl:template match="wadl:method">

=== <xsl:value-of select="@name" /> ===
	<xsl:apply-templates select="wadl:doc" />

	==== Request parameters ====
	<xsl:apply-templates select="wadl:request/wadl:param" />

	==== Response ====
	<xsl:apply-templates select="wadl:response/wadl:representation" />
	<xsl:apply-templates select="wadl:response/wadl:fault" />
</xsl:template>

</xsl:stylesheet>